<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script src="./models/Http.js"></script>
</head>

<body>
    <div id="app">
        <div v-for="(item,index) of movies">
            <p>{{index | handleTitle}}</p>
        </div>
    </div>
    <script>
        new Vue({
            data: {
                movies: {}
            },
            filters: {
                handleTitle(val) {
                    if (val == 'inTheaters') {
                        return "正在热映"
                    } else if (val == 'comingSoon') {
                        return "即将上映"
                    }
                    return val
                }
            },
            async mounted() {
                // MovieHttp.getMovie('top250').then(res => {
                //     console.log(res);
                // })
                var movies = {}
                var https = ['top250', 'inTheaters', 'comingSoon'];
                for (let url of https) {
                    let result = await MovieHttp.getMovie(url);
                    movies[url] = result.data.res
                }
                // https.forEach(async (item) => {
                //     let result = await MovieHttp.getMovie(item);
                //     movies[item] = result.data.res
                // })
                this.movies = movies
                console.log(this.movies);
            }
        }).$mount("#app")
    </script>
</body>

</html>